package com.thoughtworks.khazana;

public class Player {
	private int score = 100;
	private State state;

	public Player() {
		state = new NoMagic(this);
	}

	long score() {
		return score;
	}

	public void encounter(String thing) {
		if ("Magic Potion".equals(thing)) {
			state = new Magical(this);
		} else {
			state.encounterThing(thing);
		}
	}

	public void encounter(Player otherPlayer) {
		state.encounter(otherPlayer);
	}

	void encounterUnarmedPlayer(Player otherPlayer) {
		state.encounterUnarmedPlayer(otherPlayer);
	}

	void encounterArmedPlayer(Player player) {
		state.encounterArmedPlayer(player);
	}

	public void stealFrom(Player otherPlayer) {
		score += otherPlayer.score();
		otherPlayer.score = 0;
	}

	public void winTreasure() {
		score += 100;
	}

}
